home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / WPrefs.app / NoMenuAlert.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-02  |  4.4 KB  |  142 lines

  1. /* NoMenuAlert.c - warn user that menu can't be edited with WPrefs
  2.  * 
  3.  *  WPrefs - Window Maker Preferences Program
  4.  * 
  5.  *  Copyright (c) 1999 Alfredo K. Kojima
  6.  * 
  7.  *  This program is free software; you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation; either version 2 of the License, or
  10.  *  (at your option) any later version.
  11.  *
  12.  *  This program is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with this program; if not, write to the Free Software
  19.  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
  20.  *  USA.
  21.  */
  22.  
  23.  
  24. #include "WPrefs.h"
  25.  
  26.  
  27. typedef struct NoMenuPanel {
  28.     WMWindow *wwin;
  29.  
  30.     WMLabel *text;
  31.  
  32.     WMButton *copyBtn;
  33.     WMButton *keepBtn;
  34.  
  35.     int finished;
  36.     int copy;
  37. } NoMenuPanel;
  38.  
  39.  
  40. #define MESSAGE_TEXT \
  41.     "     The menu that is being used now could not be opened. "\
  42.     "This either means that there is a syntax error in it or that "\
  43.     "the menu is in a format not supported by WPrefs (WPrefs only "\
  44.     "supports property list menus).\n"\
  45.     "     If you want to keep using the current menu, please read "\
  46.     "the '%s/%s' file, press 'Keep Current Menu' and edit it with a "\
  47.     "text editor.\n"\
  48.     "     If you want to use this editor, press 'Copy Default Menu'. "\
  49.     "It will copy the default menu and will instruct Window Maker "\
  50.     "to use it instead of the current one.\n"\
  51.     "     If you want more flexibility, keep using the current one "\
  52.     "as it allows you to use C preprocessor (cpp) macros, while being "\
  53.     "easy to edit. Window Maker supports both formats."
  54.  
  55.  
  56. static void
  57. closeCallback(WMWidget *self, void *data)
  58. {
  59.     NoMenuPanel *panel = (NoMenuPanel*)data;
  60.  
  61.     panel->finished = True;
  62. }
  63.  
  64.  
  65. static void
  66. buttonCallback(WMWidget *self, void *data)
  67. {
  68.     NoMenuPanel *panel = (NoMenuPanel*)data;
  69.  
  70.     panel->finished = True;
  71.     if (self == panel->keepBtn)
  72.     panel->copy = False;
  73.     else
  74.     panel->copy = True;
  75. }
  76.  
  77.  
  78. Bool
  79. AskMenuCopy(WMWindow *wwin)
  80. {
  81.     NoMenuPanel panel;
  82.     char buffer[2048];
  83.  
  84.     panel.wwin = WMCreatePanelForWindow(wwin, "noMenuAlert");
  85.     WMResizeWidget(panel.wwin, 430, 260);
  86.     WMSetWindowTitle(panel.wwin, "Warning");
  87.     WMSetWindowCloseAction(panel.wwin, closeCallback, &panel);
  88.  
  89.     panel.text = WMCreateLabel(panel.wwin);
  90.     WMResizeWidget(panel.text, 370, 200);
  91.     WMMoveWidget(panel.text, 30, 20);
  92.  
  93.     sprintf(buffer, 
  94.         _("     The menu that is being used now could not be opened. "
  95.     "This either means that there is a syntax error in it or that "
  96.     "the menu is in a format not supported by WPrefs (WPrefs only "
  97.     "supports property list menus).\n"
  98.     "     If you want to keep using the current menu, please read "
  99.     "the '%s/%s' file, press 'Keep Current Menu' and edit it with a "
  100.     "text editor.\n"
  101.     "     If you want to use this editor, press 'Copy Default Menu'. "
  102.     "It will copy the default menu and will instruct Window Maker "
  103.     "to use it instead of the current one.\n"
  104.     "     If you want more flexibility, keep using the current one "
  105.     "as it allows you to use C preprocessor (cpp) macros, while being "
  106.     "easy to edit. Window Maker supports both formats."),
  107.         wusergnusteppath(), "Library/WindowMaker/README");
  108.     WMSetLabelText(panel.text, buffer);
  109.  
  110.     panel.copyBtn = WMCreateCommandButton(panel.wwin);
  111.     WMResizeWidget(panel.copyBtn, 180, 24);
  112.     WMMoveWidget(panel.copyBtn, 30, 225);
  113.     WMSetButtonText(panel.copyBtn, _("Copy Default Menu"));
  114.     WMSetButtonAction(panel.copyBtn, buttonCallback, &panel);
  115.  
  116.     panel.keepBtn = WMCreateCommandButton(panel.wwin);
  117.     WMResizeWidget(panel.keepBtn, 180, 24);
  118.     WMMoveWidget(panel.keepBtn, 225, 225);
  119.     WMSetButtonText(panel.keepBtn, _("Keep Current Menu"));
  120.     WMSetButtonAction(panel.keepBtn, buttonCallback, &panel);
  121.  
  122.     WMMapSubwidgets(panel.wwin);
  123.     WMRealizeWidget(panel.wwin);
  124.     WMMapWidget(panel.wwin);
  125.  
  126.     panel.finished = False;
  127.     panel.copy = False;
  128.  
  129.     while (!panel.finished) {
  130.     XEvent event;
  131.  
  132.     WMNextEvent(WMScreenDisplay(WMWidgetScreen(panel.wwin)), &event);
  133.     WMHandleEvent(&event);
  134.     }
  135.  
  136.     WMDestroyWidget(panel.wwin);
  137.  
  138.     return panel.copy;
  139. }
  140.  
  141.  
  142.